// ************************************************************************ //
// WARNING                                                                    
// -------                                                                    
// The types declared in this file were generated from data read from a       
// Type Library. If this type library is explicitly or indirectly (via        
// another type library referring to this type library) re-imported, or the   
// 'Refresh' command of the Type Library Editor activated while editing the   
// Type Library, the contents of this file will be regenerated and all        
// manual modifications will be lost.                                         
// ************************************************************************ //

// $Rev: 18756 $
// File generated on 2013-3-21 23:23:57 from Type Library described below.

// ************************************************************************  //
// Type Lib: C:\WINDOWS\system32\msscript.ocx (1)
// LIBID: {0E59F1D2-1FBE-11D0-8FF2-00A0D10038BC}
// LCID: 0
// Helpfile: C:\WINDOWS\system32\MSSCRIPT.HLP
// HelpString: Microsoft Script Control 1.0
// DepndLst: 
//   (1) v2.0 stdole, (C:\WINDOWS\system32\stdole2.tlb)
// ************************************************************************ //

#include <vcl.h>
#pragma hdrstop

#include <olectrls.hpp>
#include <oleserver.hpp>
#if defined(USING_ATL)
#include <atl\atlvcl.h>
#endif

#include "MSScriptControl_OCX.h"

#if !defined(__PRAGMA_PACKAGE_SMART_INIT)
#define      __PRAGMA_PACKAGE_SMART_INIT
#pragma package(smart_init)
#endif

namespace Msscriptcontrol_tlb
{

IScriptProcedurePtr& TProcedure::GetDefaultInterface()
{
  if (!m_DefaultIntf)
    Connect();
  return m_DefaultIntf;
}

_di_IUnknown __fastcall TProcedure::GetDunk()
{
  _di_IUnknown diUnk;
  if (m_DefaultIntf) {
    IUnknownPtr punk = m_DefaultIntf;
    diUnk = LPUNKNOWN(punk);
  }
  return diUnk;
}

void __fastcall TProcedure::Connect()
{
  if (!m_DefaultIntf) {
    _di_IUnknown punk = GetServer();
    m_DefaultIntf = punk;
    if (ServerData->EventIID != GUID_NULL)
      ConnectEvents(GetDunk());
  }
}

void __fastcall TProcedure::Disconnect()
{
  if (m_DefaultIntf) {

    if (ServerData->EventIID != GUID_NULL)
      DisconnectEvents(GetDunk());
    m_DefaultIntf.Reset();
  }
}

void __fastcall TProcedure::BeforeDestruction()
{
  Disconnect();
}

void __fastcall TProcedure::ConnectTo(IScriptProcedurePtr intf)
{
  Disconnect();
  m_DefaultIntf = intf;
  if (ServerData->EventIID != GUID_NULL)
    ConnectEvents(GetDunk());
}

void __fastcall TProcedure::InitServerData()
{
  static Oleserver::TServerData sd;
  sd.ClassID = CLSID_Procedure;
  sd.IntfIID = __uuidof(IScriptProcedure);
  sd.EventIID= GUID_NULL;
  ServerData = &sd;
}

BSTR __fastcall TProcedure::get_Name(void)
{
  BSTR pbstrName = 0;
  OLECHECK(GetDefaultInterface()->get_Name((BSTR*)&pbstrName));
  return pbstrName;
}

long __fastcall TProcedure::get_NumArgs(void)
{
  long pcArgs;
  OLECHECK(GetDefaultInterface()->get_NumArgs((long*)&pcArgs));
  return pcArgs;
}

VARIANT_BOOL __fastcall TProcedure::get_HasReturnValue(void)
{
  VARIANT_BOOL pfHasReturnValue;
  OLECHECK(GetDefaultInterface()->get_HasReturnValue((VARIANT_BOOL*)&pfHasReturnValue));
  return pfHasReturnValue;
}

IScriptProcedureCollectionPtr& TProcedures::GetDefaultInterface()
{
  if (!m_DefaultIntf)
    Connect();
  return m_DefaultIntf;
}

_di_IUnknown __fastcall TProcedures::GetDunk()
{
  _di_IUnknown diUnk;
  if (m_DefaultIntf) {
    IUnknownPtr punk = m_DefaultIntf;
    diUnk = LPUNKNOWN(punk);
  }
  return diUnk;
}

void __fastcall TProcedures::Connect()
{
  if (!m_DefaultIntf) {
    _di_IUnknown punk = GetServer();
    m_DefaultIntf = punk;
    if (ServerData->EventIID != GUID_NULL)
      ConnectEvents(GetDunk());
  }
}

void __fastcall TProcedures::Disconnect()
{
  if (m_DefaultIntf) {

    if (ServerData->EventIID != GUID_NULL)
      DisconnectEvents(GetDunk());
    m_DefaultIntf.Reset();
  }
}

void __fastcall TProcedures::BeforeDestruction()
{
  Disconnect();
}

void __fastcall TProcedures::ConnectTo(IScriptProcedureCollectionPtr intf)
{
  Disconnect();
  m_DefaultIntf = intf;
  if (ServerData->EventIID != GUID_NULL)
    ConnectEvents(GetDunk());
}

void __fastcall TProcedures::InitServerData()
{
  static Oleserver::TServerData sd;
  sd.ClassID = CLSID_Procedures;
  sd.IntfIID = __uuidof(IScriptProcedureCollection);
  sd.EventIID= GUID_NULL;
  ServerData = &sd;
}

LPUNKNOWN __fastcall TProcedures::get__NewEnum(void)
{
  LPUNKNOWN ppenumProcedures;
  OLECHECK(GetDefaultInterface()->get__NewEnum((LPUNKNOWN*)&ppenumProcedures));
  return ppenumProcedures;
}

Msscriptcontrol_tlb::IScriptProcedure* __fastcall TProcedures::get_Item(VARIANT Index/*[in]*/)
{
  Msscriptcontrol_tlb::IScriptProcedure* ppdispProcedure = 0;
  OLECHECK(GetDefaultInterface()->get_Item(Index, (Msscriptcontrol_tlb::IScriptProcedure**)&ppdispProcedure));
  return ppdispProcedure;
}

long __fastcall TProcedures::get_Count(void)
{
  long plCount;
  OLECHECK(GetDefaultInterface()->get_Count((long*)&plCount));
  return plCount;
}

IScriptModulePtr& TModule::GetDefaultInterface()
{
  if (!m_DefaultIntf)
    Connect();
  return m_DefaultIntf;
}

_di_IUnknown __fastcall TModule::GetDunk()
{
  _di_IUnknown diUnk;
  if (m_DefaultIntf) {
    IUnknownPtr punk = m_DefaultIntf;
    diUnk = LPUNKNOWN(punk);
  }
  return diUnk;
}

void __fastcall TModule::Connect()
{
  if (!m_DefaultIntf) {
    _di_IUnknown punk = GetServer();
    m_DefaultIntf = punk;
    if (ServerData->EventIID != GUID_NULL)
      ConnectEvents(GetDunk());
  }
}

void __fastcall TModule::Disconnect()
{
  if (m_DefaultIntf) {

    if (ServerData->EventIID != GUID_NULL)
      DisconnectEvents(GetDunk());
    m_DefaultIntf.Reset();
  }
}

void __fastcall TModule::BeforeDestruction()
{
  Disconnect();
}

void __fastcall TModule::ConnectTo(IScriptModulePtr intf)
{
  Disconnect();
  m_DefaultIntf = intf;
  if (ServerData->EventIID != GUID_NULL)
    ConnectEvents(GetDunk());
}

void __fastcall TModule::InitServerData()
{
  static Oleserver::TServerData sd;
  sd.ClassID = CLSID_Module;
  sd.IntfIID = __uuidof(IScriptModule);
  sd.EventIID= GUID_NULL;
  ServerData = &sd;
}

void __fastcall TModule::AddCode(BSTR Code/*[in]*/)
{
  GetDefaultInterface()->AddCode(Code/*[in]*/);
}

VARIANT __fastcall TModule::Eval(BSTR Expression/*[in]*/)
{
  VARIANT pvarResult;
  OLECHECK(GetDefaultInterface()->Eval(Expression, (VARIANT*)&pvarResult));
  return pvarResult;
}

void __fastcall TModule::ExecuteStatement(BSTR Statement/*[in]*/)
{
  GetDefaultInterface()->ExecuteStatement(Statement/*[in]*/);
}

VARIANT __fastcall TModule::Run(BSTR ProcedureName/*[in]*/, LPSAFEARRAY* Parameters/*[in]*/)
{
  VARIANT pvarResult;
  OLECHECK(GetDefaultInterface()->Run(ProcedureName, Parameters, (VARIANT*)&pvarResult));
  return pvarResult;
}

BSTR __fastcall TModule::get_Name(void)
{
  BSTR pbstrName = 0;
  OLECHECK(GetDefaultInterface()->get_Name((BSTR*)&pbstrName));
  return pbstrName;
}

LPDISPATCH __fastcall TModule::get_CodeObject(void)
{
  LPDISPATCH ppdispObject;
  OLECHECK(GetDefaultInterface()->get_CodeObject((LPDISPATCH*)&ppdispObject));
  return ppdispObject;
}

Msscriptcontrol_tlb::IScriptProcedureCollectionPtr __fastcall TModule::get_Procedures(void)
{
  Msscriptcontrol_tlb::IScriptProcedureCollectionPtr ppdispProcedures;
  OLECHECK(GetDefaultInterface()->get_Procedures(&ppdispProcedures));
  return ppdispProcedures;
}

IScriptModuleCollectionPtr& TModules::GetDefaultInterface()
{
  if (!m_DefaultIntf)
    Connect();
  return m_DefaultIntf;
}

_di_IUnknown __fastcall TModules::GetDunk()
{
  _di_IUnknown diUnk;
  if (m_DefaultIntf) {
    IUnknownPtr punk = m_DefaultIntf;
    diUnk = LPUNKNOWN(punk);
  }
  return diUnk;
}

void __fastcall TModules::Connect()
{
  if (!m_DefaultIntf) {
    _di_IUnknown punk = GetServer();
    m_DefaultIntf = punk;
    if (ServerData->EventIID != GUID_NULL)
      ConnectEvents(GetDunk());
  }
}

void __fastcall TModules::Disconnect()
{
  if (m_DefaultIntf) {

    if (ServerData->EventIID != GUID_NULL)
      DisconnectEvents(GetDunk());
    m_DefaultIntf.Reset();
  }
}

void __fastcall TModules::BeforeDestruction()
{
  Disconnect();
}

void __fastcall TModules::ConnectTo(IScriptModuleCollectionPtr intf)
{
  Disconnect();
  m_DefaultIntf = intf;
  if (ServerData->EventIID != GUID_NULL)
    ConnectEvents(GetDunk());
}

void __fastcall TModules::InitServerData()
{
  static Oleserver::TServerData sd;
  sd.ClassID = CLSID_Modules;
  sd.IntfIID = __uuidof(IScriptModuleCollection);
  sd.EventIID= GUID_NULL;
  ServerData = &sd;
}

Msscriptcontrol_tlb::IScriptModule* __fastcall TModules::Add(BSTR Name/*[in]*/, 
                                                             VARIANT* Object/*[in,opt]*/)
{
  Msscriptcontrol_tlb::IScriptModule* ppmod = 0;
  OLECHECK(GetDefaultInterface()->Add(Name, Object, (Msscriptcontrol_tlb::IScriptModule**)&ppmod));
  return ppmod;
}

LPUNKNOWN __fastcall TModules::get__NewEnum(void)
{
  LPUNKNOWN ppenumContexts;
  OLECHECK(GetDefaultInterface()->get__NewEnum((LPUNKNOWN*)&ppenumContexts));
  return ppenumContexts;
}

Msscriptcontrol_tlb::IScriptModule* __fastcall TModules::get_Item(VARIANT Index/*[in]*/)
{
  Msscriptcontrol_tlb::IScriptModule* ppmod = 0;
  OLECHECK(GetDefaultInterface()->get_Item(Index, (Msscriptcontrol_tlb::IScriptModule**)&ppmod));
  return ppmod;
}

long __fastcall TModules::get_Count(void)
{
  long plCount;
  OLECHECK(GetDefaultInterface()->get_Count((long*)&plCount));
  return plCount;
}

IScriptErrorPtr& TError::GetDefaultInterface()
{
  if (!m_DefaultIntf)
    Connect();
  return m_DefaultIntf;
}

_di_IUnknown __fastcall TError::GetDunk()
{
  _di_IUnknown diUnk;
  if (m_DefaultIntf) {
    IUnknownPtr punk = m_DefaultIntf;
    diUnk = LPUNKNOWN(punk);
  }
  return diUnk;
}

void __fastcall TError::Connect()
{
  if (!m_DefaultIntf) {
    _di_IUnknown punk = GetServer();
    m_DefaultIntf = punk;
    if (ServerData->EventIID != GUID_NULL)
      ConnectEvents(GetDunk());
  }
}

void __fastcall TError::Disconnect()
{
  if (m_DefaultIntf) {

    if (ServerData->EventIID != GUID_NULL)
      DisconnectEvents(GetDunk());
    m_DefaultIntf.Reset();
  }
}

void __fastcall TError::BeforeDestruction()
{
  Disconnect();
}

void __fastcall TError::ConnectTo(IScriptErrorPtr intf)
{
  Disconnect();
  m_DefaultIntf = intf;
  if (ServerData->EventIID != GUID_NULL)
    ConnectEvents(GetDunk());
}

void __fastcall TError::InitServerData()
{
  static Oleserver::TServerData sd;
  sd.ClassID = CLSID_Error;
  sd.IntfIID = __uuidof(IScriptError);
  sd.EventIID= GUID_NULL;
  ServerData = &sd;
}

void __fastcall TError::Clear(void)
{
  GetDefaultInterface()->Clear();
}

long __fastcall TError::get_Number(void)
{
  long plNumber;
  OLECHECK(GetDefaultInterface()->get_Number((long*)&plNumber));
  return plNumber;
}

BSTR __fastcall TError::get_Source(void)
{
  BSTR pbstrSource = 0;
  OLECHECK(GetDefaultInterface()->get_Source((BSTR*)&pbstrSource));
  return pbstrSource;
}

BSTR __fastcall TError::get_Description(void)
{
  BSTR pbstrDescription = 0;
  OLECHECK(GetDefaultInterface()->get_Description((BSTR*)&pbstrDescription));
  return pbstrDescription;
}

BSTR __fastcall TError::get_HelpFile(void)
{
  BSTR pbstrHelpFile = 0;
  OLECHECK(GetDefaultInterface()->get_HelpFile((BSTR*)&pbstrHelpFile));
  return pbstrHelpFile;
}

long __fastcall TError::get_HelpContext(void)
{
  long plHelpContext;
  OLECHECK(GetDefaultInterface()->get_HelpContext((long*)&plHelpContext));
  return plHelpContext;
}

BSTR __fastcall TError::get_Text(void)
{
  BSTR pbstrText = 0;
  OLECHECK(GetDefaultInterface()->get_Text((BSTR*)&pbstrText));
  return pbstrText;
}

long __fastcall TError::get_Line(void)
{
  long plLine;
  OLECHECK(GetDefaultInterface()->get_Line((long*)&plLine));
  return plLine;
}

long __fastcall TError::get_Column(void)
{
  long plColumn;
  OLECHECK(GetDefaultInterface()->get_Column((long*)&plColumn));
  return plColumn;
}



// *********************************************************************//
// OCX PROXY CLASS IMPLEMENTATION
// (The following variables/methods implement the class TScriptControl which
// allows "Control to host scripting engines that understand the ActiveX Scripting interface" to be hosted in CBuilder IDE/apps).
// *********************************************************************//
int   TScriptControl::EventDispIDs[2] = {
    0x00000BB8, 0x00000BB9};

TControlData2 TScriptControl::CControlData =
{
  // GUID of CoClass and Event Interface of Control
  {0x0E59F1D5, 0x1FBE, 0x11D0,{ 0x8F, 0xF2, 0x00,0xA0, 0xD1, 0x00,0x38, 0xBC} }, // CoClass
  {0x8B167D60, 0x8605, 0x11D0,{ 0xAB, 0xCB, 0x00,0xA0, 0xC9, 0x0F,0xFF, 0xC0} }, // Events

  // Count of Events and array of their DISPIDs
  2, &EventDispIDs,

  // Pointer to Runtime License string
  NULL,  // HRESULT(0x00000000)

  // Flags for OnChanged PropertyNotification
  0x00000000,
  401,// (IDE Version)

  // Count of Font Prop and array of their DISPIDs
  0, Activex::PDispIDList(NULL),

  // Count of Pict Prop and array of their DISPIDs
  0, Activex::PDispIDList(NULL),
  0, // Reserved
  0, // Instance count (used internally)
  0, // List of Enum descriptions (internal)
};

GUID     TScriptControl::DEF_CTL_INTF = {0x0E59F1D3, 0x1FBE, 0x11D0,{ 0x8F, 0xF2, 0x00,0xA0, 0xD1, 0x00,0x38, 0xBC} };
TNoParam TScriptControl::OptParam;

static inline void ValidCtrCheck(TScriptControl *)
{
   delete new TScriptControl((TComponent*)(0));
};

void __fastcall TScriptControl::InitControlData()
{
  ControlData = (TControlData*)&CControlData;
  CControlData.FirstEventOfs = System::PByte(&FOnError) - System::PByte(this);
};

void __fastcall TScriptControl::CreateControl()
{
  if (!m_OCXIntf)
  {
    _ASSERTE(DefaultDispatch);
    DefaultDispatch->QueryInterface(DEF_CTL_INTF, (LPVOID*)&m_OCXIntf);
  }
};

TCOMIScriptControl __fastcall TScriptControl::GetDefaultInterface()
{
  CreateControl();
  return m_OCXIntf;
};

void __fastcall TScriptControl::_AboutBox(void)
{
  GetDefaultInterface()->_AboutBox();
}

void __fastcall TScriptControl::AddObject(BSTR Name/*[in]*/, LPDISPATCH Object/*[in]*/, 
                                          VARIANT_BOOL AddMembers/*[in,def,opt]*/)
{
  GetDefaultInterface()->AddObject(Name/*[in]*/, Object/*[in]*/, AddMembers/*[in,def,opt]*/);
}

void __fastcall TScriptControl::Reset(void)
{
  GetDefaultInterface()->Reset();
}

void __fastcall TScriptControl::AddCode(BSTR Code/*[in]*/)
{
  GetDefaultInterface()->AddCode(Code/*[in]*/);
}

VARIANT __fastcall TScriptControl::Eval(BSTR Expression/*[in]*/)
{
  VARIANT pvarResult;
  OLECHECK(GetDefaultInterface()->Eval(Expression, (VARIANT*)&pvarResult));
  return pvarResult;
}

void __fastcall TScriptControl::ExecuteStatement(BSTR Statement/*[in]*/)
{
  GetDefaultInterface()->ExecuteStatement(Statement/*[in]*/);
}

VARIANT __fastcall TScriptControl::Run(BSTR ProcedureName/*[in]*/, LPSAFEARRAY* Parameters/*[in]*/)
{
  VARIANT pvarResult;
  OLECHECK(GetDefaultInterface()->Run(ProcedureName, Parameters, (VARIANT*)&pvarResult));
  return pvarResult;
}

Msscriptcontrol_tlb::IScriptModuleCollectionPtr __fastcall TScriptControl::get_Modules(void)
{
  Msscriptcontrol_tlb::IScriptModuleCollectionPtr ppmods;
  OLECHECK(GetDefaultInterface()->get_Modules(&ppmods));
  return ppmods;
}

Msscriptcontrol_tlb::IScriptErrorPtr __fastcall TScriptControl::get_Error(void)
{
  Msscriptcontrol_tlb::IScriptErrorPtr ppse;
  OLECHECK(GetDefaultInterface()->get_Error(&ppse));
  return ppse;
}

LPDISPATCH __fastcall TScriptControl::get_CodeObject(void)
{
  LPDISPATCH ppdispObject;
  OLECHECK(GetDefaultInterface()->get_CodeObject((LPDISPATCH*)&ppdispObject));
  return ppdispObject;
}

Msscriptcontrol_tlb::IScriptProcedureCollectionPtr __fastcall TScriptControl::get_Procedures(void)
{
  Msscriptcontrol_tlb::IScriptProcedureCollectionPtr ppdispProcedures;
  OLECHECK(GetDefaultInterface()->get_Procedures(&ppdispProcedures));
  return ppdispProcedures;
}


};     // namespace Msscriptcontrol_tlb


// *********************************************************************//
// The Register function is invoked by the IDE when this module is 
// installed in a Package. It provides the list of Components (including
// OCXes) implemented by this module. The following implementation
// informs the IDE of the OCX proxy classes implemented here.
// *********************************************************************//
namespace Msscriptcontrol_ocx
{

void __fastcall PACKAGE Register()
{
  // [1]
  TComponentClass cls_ocx[] = {
                              __classid(Msscriptcontrol_tlb::TScriptControl)
                           };
  RegisterComponents("ActiveX", cls_ocx,
                     sizeof(cls_ocx)/sizeof(cls_ocx[0])-1);
  // [5]
  TComponentClass cls_svr[] = {
                              __classid(Msscriptcontrol_tlb::TProcedure), 
                              __classid(Msscriptcontrol_tlb::TProcedures), 
                              __classid(Msscriptcontrol_tlb::TModule), 
                              __classid(Msscriptcontrol_tlb::TModules), 
                              __classid(Msscriptcontrol_tlb::TError)
                           };
  RegisterComponents("ActiveX", cls_svr,
                     sizeof(cls_svr)/sizeof(cls_svr[0])-1);
}

};     // namespace Msscriptcontrol_ocx
